const express = require("express")
const app = express()
const path = require("path")
app.get("/b/:page?",(req,res)=>{
    const { page } = req.params
    let arr = [1,2,3,4,5,6,7,8,9,10]
    if(page === "1"){
        res.send(arr.slice(0,5))
    }else if(page === "2"){
        res.send(arr.slice(5,10))
    }else{
        res.send(arr.slice(0,5))
    }  
})
app.get("/c",(req,res)=>{
    res.sendFile(path.resolve(__dirname,"lsp.jpg"))
    // console.log(path.resolve(__dirname,"lsp.jpg"));
})


app.listen(5000,(err)=>{
    if(err){
        console.log("服务器启动失败")
    }else{
        console.log("服务器启动成功")
    }
})